using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using System.IO;
using System.ComponentModel;

namespace FolderData
{
    [ContentProcessor(DisplayName = "YanderehProcessors.KoreanFontProcessor")]
    public class KoreanFontProcessor : FontDescriptionProcessor
    {
        [DefaultValue("Scripts/Scene")]
        [DisplayName("Scene scripts directory path")]
        [Description("Scene scripts directory path. All contents in this directory will be ready to rendered.")]
        public string DirPath
        {
            get { return dirPath; }
            set { dirPath = value; }
        }
        private string dirPath = "Scripts/Scene";

        public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
        {
            string fullPath = Path.GetFullPath(DirPath);
            context.AddDependency(fullPath);

            foreach (string filename in Directory.GetFiles(fullPath))
            {
                string fullname = Path.GetFullPath(filename);
                context.AddDependency(fullname);

                string letters = File.ReadAllText(fullname, System.Text.Encoding.UTF8);
                foreach (char c in letters)
                {
                    input.Characters.Add(c);
                }
            }

            return base.Process(input, context);
        }
    }
}
